package com.example.mapp;

import com.example.entity.PeriodicalInspection;
import org.apache.ibatis.annotations.*;

/**
 * Created by youkun on 2017/9/22.
 */
@Mapper
public interface PeriodicalInspectionMapp {

    @Select(" select * from periodical_inspection  where id=#{id}")
    PeriodicalInspection queryById(String id) throws Exception;

    @Delete("delete from periodical_inspection  where id=#{id}")
    int deleteById(String id)throws Exception;

    @Insert(" insert into periodical_inspection " +
            "(acceptance_num,inspection_party_id,used_party_id,maintenance_party_id," +
            "used_contact_name,used_contact_phone,maintenance_user_name,maintenance_user_phone," +
            "elevator_num,hoisting_machinery_num,factory_vehicle_num,amusement_facilities_num," +
            "used_contact_sign_url,report_date_time,elevator_ids,is_acceptance,enclosure_urls)" +
            " value " +
            "(#{acceptanceNum},#{inspectionPartyId},#{usedPartyId},#{maintenancePartyId}," +
            "#{usedContactName},#{usedContactPhone},#{maintenanceUserName},#{maintenanceUserPhone}," +
            "#{elevatorNum},#{hoistingMachineryNum},#{factoryVehicleNum},#{amusementFacilitiesNum},#{usedContactSignUrl}" +
            ",#{reportDateTime},#{elevatorIds},#{isAcceptance},#{enclosureUrls})")
    @SelectKey(statement="select last_insert_id()",keyProperty = "id",keyColumn = "id",before = false,resultType = Long.class)
    int add(PeriodicalInspection periodicalInspection)throws Exception;

    @Update("update periodical_inspection set acceptance_num=#{acceptanceNum} where id=#{id}")
    int update(PeriodicalInspection periodicalInspection) throws Exception;
}
